package io.renren.modules.canteens.dao;

import io.renren.common.dao.BaseDao;
import io.renren.modules.canteens.dto.StockOrderDTO;
import io.renren.modules.canteens.entity.StockOrderEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 食材采购表
 *
 * @author 翟文闯 619556390@QQ.com
 * @since 1.0.0 2019-11-22
 */
@Mapper
public interface StockOrderDao extends BaseDao<StockOrderEntity> {


    @Select("SELECT  sum(b.unit_price*b.arrival_num) as totalPrice,A.* FROM canteens_stock_order A ,canteens_stock_ordermx B where a.stock_order_id = b.stock_order_id " +
            "and  A.status>=4 and A.canteen_id = '${canteenId}' ${createDate}  GROUP BY A.stock_order_id ${paging}")
    List<StockOrderDTO> getOrderList(String  createDate,long canteenId,String paging);
    @Select("SELECT  sum(b.unit_price*b.arrival_num)as totalPrice,A.* FROM canteens_stock_order A ,canteens_stock_ordermx B where a.stock_order_id = b.stock_order_id " +
            "and  A.status>=4 and A.canteen_id = '${canteenId}' ${createDate} ")
    StockOrderDTO getOrdertotalMony(String  createDate,long canteenId);

    @Select(" SELECT  COUNT(*) as totalPage FROM canteens_stock_order A where  A.status>=4 and DATE_FORMAT(A.create_date,'%Y-%m')=DATE_FORMAT('2020-01-01','%Y-%m') and  canteen_id = '${canteenId}' ")
    StockOrderDTO getTotalPage(String  createDate,long canteenId);
}